* {
    margin: 0;
    padding: 0;
}

/* body 设置为弹性盒，是为了让 container 水平垂直居中 */

body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 最外层容器 */

.container {
    width: 8em;
    height: 1em;
    /* outline: 1px solid; */
    font-size: 35px;
    display: flex;
    justify-content: space-between;
}

/* 设置所有的 span 元素样式 */

.container span {
    width: 1em;
    height: 1em;
    /* outline: 1px solid; */
}

/* 蓝色方块容器样式 */

.boys {
    width: 6em;
    display: flex;
    justify-content: space-between;
}

/* 有了伪元素的知识后，我们可以设置小方块的阴影以及颜色 */

.container span::before {
    content: '';
    position: absolute;
    width: 1em;
    height: 1em;
    border-radius: 15%;
    box-shadow: 0 0 0.1em rgba(0, 0, 0, 0.3);
}

/* 粉红色方块设置背景色 */

.girl::before {
    background-color: hotpink;
}

/* 蓝色方块设置背景色 */

.boys span::before {
    background-color: dodgerblue;
}

/* 至此，我们的元素布局已经完成，下面开始书写动画 */

/* 在开始书写动画前，我们需要一些前置知识：CSS 变形、滤镜、动画 */

/* 使用粉色盒子左右移动动画 */

.girl {
    animation: slide 1.5s ease-in-out infinite alternate;
}

/* 定义粉色盒子左右移动动画 */

@keyframes slide {
    0% {
        transform: translateX(0);
        filter: brightness(1);
    }
    100% {
        transform: translateX(236px);
        filter: brightness(1.45);
    }
}

/* 使用蓝色盒子跳动动画 */

.boys span {
    animation: 1.5s ease-in-out infinite alternate;
}

.boys span:nth-child(1) {
    animation-name: jump-off-1;
}

.boys span:nth-child(2) {
    animation-name: jump-off-2;
}

.boys span:nth-child(3) {
    animation-name: jump-off-3;
}

.boys span:nth-child(4) {
    animation-name: jump-off-4;
}

/* 定义第一个蓝色盒子跳动动画 */

@keyframes jump-off-1 {
    0%, 15% {
        transform: rotate(0deg);
    }
    35%, 100% {
        transform-origin: -50% center;
        transform: rotate(-180deg);
    }
}

/* 定义第二个蓝色盒子跳动动画 */

@keyframes jump-off-2 {
    0%, 30% {
        transform: rotate(0deg);
    }
    50%, 100% {
        transform-origin: -50% center;
        transform: rotate(-180deg);
    }
}

/* 定义第三个蓝色盒子跳动动画 */

@keyframes jump-off-3 {
    0%, 45% {
        transform: rotate(0deg);
    }
    65%, 100% {
        transform-origin: -50% center;
        transform: rotate(-180deg);
    }
}

/* 定义第四个蓝色盒子跳动动画 */

@keyframes jump-off-4 {
    0%, 60% {
        transform: rotate(0deg);
    }
    80%, 100% {
        transform-origin: -50% center;
        transform: rotate(-180deg);
    }
}

/* 为伪元素设置动画，因为我们的颜色是设置在伪元素上面的 */

.boys span::before {
    animation: 1.5s ease-in-out infinite alternate;
}

/* 蓝色盒子添加滤镜效果 */

.boys span:nth-child(1)::before {
    filter: brightness(1);
    animation-name: jump-down-1;
}

.boys span:nth-child(2)::before {
    filter: brightness(1.15);
    animation-name: jump-down-2;
}

.boys span:nth-child(3)::before {
    filter: brightness(1.3);
    animation-name: jump-down-3;
}

.boys span:nth-child(4)::before {
    filter: brightness(1.45);
    animation-name: jump-down-4;
}

/* 第一个蓝色盒子缩放的动画 */

@keyframes jump-down-1 {
    5% {
        transform: scale(1, 1);
    }
    15% {
        transform-origin: center bottom;
        transform: scale(1.3, 0.7);
    }
    20%, 25% {
        transform-origin: center bottom;
        transform: scale(0.8, 1.4);
    }
    40% {
        transform-origin: center top;
        transform: scale(1.3, 0.7);
    }
    55%, 100% {
        transform: scale(1, 1);
    }
}

/* 第二个蓝色盒子缩放的动画 */

@keyframes jump-down-2 {
    20% {
        transform: scale(1, 1);
    }
    30% {
        transform-origin: center bottom;
        transform: scale(1.3, 0.7);
    }
    35%, 40% {
        transform-origin: center bottom;
        transform: scale(0.8, 1.4);
    }
    55% {
        transform-origin: center top;
        transform: scale(1.3, 0.7);
    }
    70%, 100% {
        transform: scale(1, 1);
    }
}

/* 第三个蓝色盒子缩放的动画 */

@keyframes jump-down-3 {
    35% {
        transform: scale(1, 1);
    }
    45% {
        transform-origin: center bottom;
        transform: scale(1.3, 0.7);
    }
    50%, 55% {
        transform-origin: center bottom;
        transform: scale(0.8, 1.4);
    }
    70% {
        transform-origin: center top;
        transform: scale(1.3, 0.7);
    }
    85%, 100% {
        transform: scale(1, 1);
    }
}

/* 第四个蓝色盒子缩放的动画 */

@keyframes jump-down-4 {
    50% {
        transform: scale(1, 1);
    }
    60% {
        transform-origin: center bottom;
        transform: scale(1.3, 0.7);
    }
    65%, 70% {
        transform-origin: center bottom;
        transform: scale(0.8, 1.4);
    }
    85% {
        transform-origin: center top;
        transform: scale(1.3, 0.7);
    }
    100%, 100% {
        transform: scale(1, 1);
    }
}
